/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package manager;

import dao.UserDao;
import entity.User;
import java.util.List;

/**
 *
 * @author daz
 */
public class UserManager {

    private UserDao userDao;

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    public UserDao getUserDao() {
        return userDao;
    }

    public void insertUser(String name, String pass, String age, String address, String phone, String email, String sex) {
        userDao.insertUser(name, pass, age, address, phone, email, sex);
    }

    public User searchUser(String name) {
        List<User> listUsers = userDao.searchUser(name);
        if (listUsers.isEmpty()) {
            return null;
        } else {
            return listUsers.get(0);
        }
    }

    public User searchUser(int id) {
        List<User> listUsers = userDao.searchUser(id);
        if (listUsers.isEmpty()) {
            return null;
        } else {
            return listUsers.get(0);
        }
    }
}
